from Modules.PHPStudy import PHPStudyBackdoor
from ClassCongregation import AgentHeader,ExploitOutput
import os

#可交互式漏洞利用列表
ExploitModuleList={
"PHPStudyBackdoor":PHPStudyBackdoor.exploit,

}
#反序列化的漏洞列表
DeserializationModuleList={

}

def main(**kwargs):
    Module=kwargs.get("Exploit")
    Deserialization=kwargs.get("Deserialization")
    Url=kwargs.get("Url")
    RandomAgent=AgentHeader().result(kwargs.get("AgentHeader"))#获取随机头
    Proxies=kwargs.get("Proxies")
    Sid = kwargs.get("Sid")
    Uid = kwargs.get("Uid")
    # p1 = Process(target=ExploitModuleList[Module], args=(Url, RandomAgent, Proxies,), kwargs={"Sid": Sid, "Uid": Uid})
    # p1.start()
    # print('parent process:', os.getppid())
    # print('process id:', os.getpid())
    OperatingSystem = ExploitOutput().OperatingSystem()  # 获取系统名称
    if Module!=None:
        while True:
            try:
                Command = ExploitOutput().Command()  # 获取需要执行的命令
                ExploitModuleList[Module](Url, RandomAgent, Proxies,Command=Command,OperatingSystem=OperatingSystem,Sid=Sid,Uid=Uid)  # 调用列表里面的值

            except:  # 如果传入非法字符串会调用出错
                print("\033[31m[ ! ] Please enter the correct command to execute the module name\033[0m")
                os._exit(0)  # 直接退出整个函数
    elif Deserialization!=None:
        while True:
            try:
                LoadExploitURL = ExploitOutput().Deserialization()  # 获取需要加载的反序列化
                ExploitModuleList[Module](Url, RandomAgent, Proxies, LoadExploitURL=LoadExploitURL,Sid=Sid, Uid=Uid)  # 调用列表里面的值

            except:  # 如果传入非法字符串会调用出错
                print("\033[31m[ ! ] Please enter the correct command to execute the module name\033[0m")
                os._exit(0)  # 直接退出整个函数
